﻿namespace Ocelot.Admin.Api.Application
{
    /// <summary>
    /// 字典接口
    /// </summary>
    public class DictionaryApiController : IDynamicApiController
    {
        private readonly IDictionaryService _dictionaryService;
        private readonly IDictionaryCacheService _dictionaryCacheService;
        public DictionaryApiController(IDictionaryService dictionaryService, IDictionaryCacheService dictionaryCacheService)
        {
            _dictionaryService = dictionaryService;
            _dictionaryCacheService = dictionaryCacheService;
        }

        #region 查询

        /// <summary>
        /// 分页查询字典信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task<SqlSugarPagedList<Dictionary>> GetPageDictionaryAsync([FromQuery] BasePageRequest request)
        {
            return await _dictionaryService.GetPageDictionaryAsync(request);
        }

        /// <summary>
        /// 查询字典项信息
        /// </summary>
        /// <param name="dictionaryType"></param>
        /// <returns></returns>

        public async Task<List<BaseSelectDto<string>>> GetDictionaryItemAsync(string dictionaryType)
        {
            return await _dictionaryService.GetDictionaryItemAsync(dictionaryType);
        }

        /// <summary>
        /// 获取所有下拉框
        /// </summary>
        /// <returns></returns>
        public async Task<AllSelectResponse> GetAllSelectAsync()
        {
            return await _dictionaryCacheService.GetAllSelectAsync();
        }

        #endregion
    }
}